package com.amsp.oa.oademo.controller;

import com.amsp.oa.oademo.entity.LaborTermination;
import com.amsp.oa.oademo.service.LaborTerminationService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "劳动合同解除协议管理")
@RestController
@RequestMapping("/api/labor-termination")
public class LaborTerminationController {

    @Autowired
    private LaborTerminationService laborTerminationService;

    @ApiOperation("分页查询")
    @GetMapping("/page")
    public IPage<LaborTermination> getPage(
            @ApiParam("当前页") @RequestParam(defaultValue = "1") Integer current,
            @ApiParam("每页大小") @RequestParam(defaultValue = "10") Integer size,
            @ApiParam("乙方姓名") @RequestParam(required = false) String bParty) {
        return laborTerminationService.getPage(current, size, bParty);
    }

    @ApiOperation("根据ID查询")
    @GetMapping("/{id}")
    public LaborTermination getById(@PathVariable Long id) {
        return laborTerminationService.getById(id);
    }

    @ApiOperation("保存或更新")
    @PostMapping("/save")
    public boolean save(@RequestBody List<LaborTermination> list) {
        return laborTerminationService.saveOrUpdateBatch(list);
    }

    @ApiOperation("根据ID删除")
    @DeleteMapping("/{id}")
    public boolean removeById(@PathVariable Long id) {
        return laborTerminationService.removeById(id);
    }

    @ApiOperation("批量删除")
    @DeleteMapping("/batch")
    public boolean removeBatchByIds(@RequestBody List<Long> ids) {
        return laborTerminationService.removeBatchByIds(ids);
    }
}